import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'

Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    userInfo: null,
    ticket: '',
    name: '',
    corpId: '',
    agentId: ''
  },
  mutations: {
    SET_USERINFO(state, user) {
      state.userInfo = user
    },
    SET_TICKET(state, ticket) {
      state.ticket = ticket
    },
    SET_NAME(state, name) {
      state.name = name
    },
    SET_CORPID(state, name) {
      state.corpId = name
    },
    SET_AGENTID(state, name) {
      state.agentId = name
    }
  },
  getters: {
    userInfo: state => state.userInfo,
    ticket: state => state.ticket,
    name: state => state.name,
    corpId: state => state.corpId,
    agentId: state => state.agentId
  },
  plugins: [persistedState()]
})

export default store
